package com.ruoyi.system.controller;

import com.ruoyi.system.domain.dto.ElecImportDto;
import com.ruoyi.system.domain.vo.ElecImportInfoVo;
import com.ruoyi.system.service.ElecImportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author xy
 * @version 1.0
 * @description:
 * @date 2024/7/5 9:55
 */
@RestController
@RequestMapping("/system/elecImport")
@Api(tags = "用电报告模块")
public class ElecImportController {
    @Autowired
    private ElecImportService service;

    @GetMapping("/info")
    @ApiOperation("查询账单对应的用电报告")
    public ElecImportInfoVo getElecImportInfo(@ApiParam(name = "usageId", value = "用电账单ID", required = true) @Param("usageId") Long usageId) {
        return service.selectElecImportInfoByUsageId(usageId);
    }

    @PostMapping
    @ApiOperation("新增账单对应的用电报告")
    public int insertElecImport(@ApiParam(name = "usageId", value = "用电账单ID", required = true) @RequestBody ElecImportDto dto) {
        Long usageId = dto.getUsageId();
        return service.insertElecImportByUsageId(usageId);
    }
}
